//
//  TJPayWayListController.m
//  Teleport
//
//  Created by xtjun on 2020/6/13.
//  Copyright © 2020 xtjun. All rights reserved.
//

#import "TJPayWayListController.h"
#import "TJAddPayWayController.h"

@interface TJPayWayListController ()

@property (strong, nonatomic) NSArray *datas;


@end

@implementation TJPayWayListController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.navigationBar.title = @"支付方式".localizedString;

       self.tableView.backgroundColor = UIColor.whiteColor;
       self.tableView.showsVerticalScrollIndicator = NO;
       self.tableView.rowHeight = 60;
       [self.tableView registerClass:TJStyle1Cell.self forCellReuseIdentifier:style1Cell];
       [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
           make.top.offset(KNavBarHight);
           make.left.right.bottom.offset(0);
       }];
    

    

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.datas.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TJStyle1Cell *cell = [tableView dequeueReusableCellWithIdentifier:style1Cell forIndexPath:indexPath];
    cell.model = self.datas[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    TJCellStyleModel *model = self.datas[indexPath.row];
    if ([model.identification isEqualToString:@"bank"]) {
        
        [self.navigationController pushViewControllerWithName:@"TJAddbankController" title:nil animated:YES];
    } else {
        TJAddPayWayController *adddPayWayController = [[TJAddPayWayController alloc] init];
        adddPayWayController.identification = model.identification;
        [self.navigationController pushViewController:adddPayWayController animated:YES];
    }
    
}

 - (NSArray *)datas {
     if (!_datas) {
         NSArray *arr = @[
             @{
                 @"icon": @"OTC_list_weChat",
                 @"text": @"微信".localizedString,
                 @"detailText": @"",
                 @"identification": @"weChat",
                 @"hasArrow": @(1),
             },
             @{
                 @"icon": @"OTC_list_Alipay",
                 @"text": @"支付宝".localizedString,
                 @"detailText": @"",
                 @"identification": @"alipay",
                 @"hasArrow": @(1),
             },
             @{
                 @"icon": @"OTC_list_bank",
                 @"text": @"银行卡".localizedString,
                 @"detailText": @"",
                 @"identification": @"bank",
                 @"hasArrow": @(1),
             }
         ];
         
         _datas = [TJCellStyleModel mj_objectArrayWithKeyValuesArray:arr];
     }
     return _datas;
     
 }

 @end
